package cn.iocoder.yudao.module.movie.pojo.convert;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.movie.api.domain.*;
import cn.iocoder.yudao.module.movie.pojo.YouPiaoPiaoDTO;
import lombok.experimental.UtilityClass;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>  </p>
 */
@UtilityClass
public class MoviesConvert {
    public static MovieListDO convert(YouPiaoPiaoDTO.Movies movies)
    {
        MovieListDO movieListDO = new MovieListDO();
        movieListDO.setCount(movies.getCount());
        if (movies.getMovies() != null) {
            List<MovieDO> movieDOList = movies.getMovies().stream().map(MoviesConvert::convert).collect(Collectors.toList());
            movieListDO.setMovies(movieDOList);
        }
        return movieListDO;
    }
    public static MovieDO convert(YouPiaoPiaoDTO.MoviesDTO moviesDTO)
    {
        return BeanUtils.toBean(moviesDTO, MovieDO.class);
    }
    public static CityDO convert(YouPiaoPiaoDTO.City city)
    {
        return BeanUtils.toBean(city, CityDO.class);
    }
    public static CinemaDO convert(YouPiaoPiaoDTO.Cinemas cinemas)
    {
        return BeanUtils.toBean(cinemas, CinemaDO.class);
    }
    public static MovieCinemasDO convert(YouPiaoPiaoDTO.MovieCinemas movieCinemas)
    {
        List<YouPiaoPiaoDTO.Cinemas> cinemas = movieCinemas.getCinemas();
        MovieCinemasDO movieCinemasDO = new MovieCinemasDO();
        movieCinemasDO.setCinemaCount(movieCinemas.getCinemaCount());
        movieCinemasDO.setShowDates(movieCinemas.getShowDates());
        movieCinemasDO.setSort(movieCinemas.getSort());
        movieCinemasDO.setSortNames(movieCinemas.getSortNames());
        if (cinemas != null) {
            List<CinemaDO> cinemaDOList = cinemas.stream().map(MoviesConvert::convert).collect(Collectors.toList());
            movieCinemasDO.setCinemas(cinemaDOList);
        }
        return movieCinemasDO;
    }
}
